import Vue from 'vue'
import Vonic from 'vonic'
import axios from 'axios'
import Vuex from 'vuex';
import sess from 'sess.js';
import '../static/css/base.css';
import '../static/js/filter.js';
import '../static/js/base.js';

import { IndexList, IndexSection } from 'mint-ui';
import 'mint-ui/lib/style.css'
Vue.component(IndexList.name, IndexList);
Vue.component(IndexSection.name, IndexSection);

console.log(Vue)
// Page Components
import index from './components/index.vue'
import home from './components/home/home.vue'
import cars from './components/home/cars.vue'
import desk from './components/home/desk.vue'
import user from './components/home/user.vue'
import detial from './components/cars/detial.vue'
import detial_mine from './components/cars/detial_mine.vue'
import add_step1 from './components/cars/add_step1.vue'
import add_step2 from './components/cars/add_step2.vue'
import login from './components/login.vue'
import iframe_che300 from './components/iframe_che300.vue'
import iframe_wx from './components/iframe_wx.vue'
//new
import statistics_home from './components/statistics/home.vue'
import statistics_tab from './components/statistics/tabs.vue'
import tablist from './components/statistics/tabs_list.vue'
import tabsection from './components/statistics/tabs_section.vue'

import notice from './components/user/notice.vue'

import noticeDetial from './components/user/noticeDetial.vue'

import staffList from './components/staff/staffList.vue'
import addStaff from './components/staff/addStaff.vue'
import editStaff from './components/staff/editStaff.vue'

import show from './components/show/show.vue'
import brandDetial from './components/show/brandDetial.vue'
import colorDetial from './components/show/colorDetial.vue'
import modelDetial from './components/show/modelDetial.vue'
import priceDetial from './components/show/priceDetial.vue'
import totalDetial from './components/show/totalDetial.vue'

import car from './components/home/cars_mine.vue'
import reserve from 'src/components/carEditor/reserve.vue'
import library from 'src/components/carEditor/library.vue'
import price from 'src/components/carEditor/price.vue'
import vehicle from 'src/components/carEditor/vehicle.vue'
import vehicle_step2 from 'src/components/carEditor/vehicle_step2.vue'
import carInfo from 'src/assembly/carInfo.vue'
import special from 'src/components/carEditor/special'
import shelves_step1 from 'src/components/carEditor/shelves_step1'
import shelves_step2 from 'src/components/carEditor/shelves_step2'
import customer from 'src/components/customer/home'
import customer_screen from 'src/components/customer/screen'
import customer_screen_info from 'src/components/customer/screen_info'
import follow from 'src/components/customer/follow'
import follow_all from 'src/components/customer/follow_all'
import follow_history from 'src/components/customer/follow_history'
import addIntention from 'src/components/customer/addIntention'
import infoIntention from 'src/components/customer/infoIntention'
import customerInfo from 'src/components/cars/customerInfo.vue'
import customerList from 'src/components/cars/customerList.vue'
import customerQuery from 'src/components/cars/customerQuery.vue'
import customer_edit from 'src/components/customer/customer_edit.vue'
import customer_add from 'src/components/customer/customer_add.vue'
import addIntentions from 'src/components/customer/addIntentions'
import select_template from 'src/components/template/select_template.vue'
import cars_template from 'src/components/template/cars_template.vue'
import cars_favorite from 'src/components/favorite/cars_favorite.vue'
import user_feedback from 'src/components/feedback/user_feedback.vue'
import user_feedback_history from 'src/components/feedback/user_feedback_history.vue'
import about from './components/about/about.vue'

import checkList from './components/check/checkList.vue'
import checkDetial from './components/check/checkDetial.vue'

import test from './components/test/test.vue'
import testcars from './components/test/cars.vue'
import testcar from './components/test/car.vue'

import customer_mail from 'src/components/customer/customer_mail.vue'
import testing from 'src/components/testing/testing.vue'
import retrieve from 'src/components/retrieve/retrieve.vue'
import cooperation from 'src/components/retrieve/cooperation.vue'
import dismissal from 'src/components/retrieve/dismissal.vue'
import edit from 'src/components/retrieve/edit.vue'
import password from 'src/components/login/password.vue'
import lease from 'src/components/lease/lease.vue'
window.baseUrl = process.env.API_ROOT;
//axios
window.axios = axios
window.sess = sess

axios.interceptors.request.use(function(config) {
	// 在发送请求之前做些什么
	$loading.show('拼命加载中..');
	return config;
}, function(error) {
	$toast.show('服务器请求错误！', 3000);
	return Promise.reject(error);
});
axios.interceptors.response.use(function(response) {
	// 对响应数据做点什么
	window.SECURITY_TOKEN = response.headers['security-token']
	if(response.data.code != 1) {
		$toast.show(response.data.msg, 3000);
		return false;
	}
	$loading.hide();
	return response;
}, function(error) {
	// 对响应错误做点什么
	$toast.show('服务器链接错误！', 3000);
	return Promise.reject(error);
});
// Routes
const routes = [{
		path: '/',
		redirect: 'login'
	},
	{
		path: '/',
		component: index,
		children: [
			{
				path: 'home',
				component: home
			},
			{
				path: 'cars',
				component: cars
			},
			{
				path: 'desk',
				component: desk
			},
			{
				path: 'user',
				component: user
			}
		]
	},
	{
		path:'/test',
		component:test,
	},
	{
		path:'/testing',
		component:testing,
//		children:[
//			{ path:'/car' ,component:testcars},
//			{ path:'/car/:id' , component:detial_mine},
//			{ path:'/reserve',component:reserve},
//			{ path:'/library',component:library},
//			{ path:'/price',component:price},
//			{ path:'/vehicle',component:vehicle},
//			{ path:'/vehicle_step2',component:vehicle_step2},
//			{ path:'/carInfo',component:carInfo},
//			{ path:'/special',component:special},
//			{ path:'/shelves_step1',component:shelves_step1},
//			{ path:'/shelves_step2',component:shelves_step2},
//		]
	},
	{
		path: '/cars/:id',
		component: detial
	},
	{
		path: '/car/:id',
		component: detial_mine
	},
	{
		path: '/customerQuery/:id/',
		component: customerQuery,
		children: [{
				path: '/',
				component: customerList
			},
			{
				path: 'customerInfo/:cusid',
				component: customerInfo
			},
		]
	},

	{
		path: '/car',
		component: car
	},
	{
		path: '/add_step1',
		component: add_step1
	},
	{
		path: '/add_step2',
		component: add_step2
	},
	{
		path: '/login/:openId',
		component: login
	},
	{
		path: '/login',
		component: login
	},
	{
		path: '/iframe_che300',
		component: iframe_che300
	},
	{
		path: '/iframe_wx',
		component: iframe_wx
	},
	{
		path: '/statistics',
		component: statistics_home,
		children: [{
			path: 'tab/:id',
			component: statistics_tab
		}]
	},
	{
		path: '/tabs/:time/:id/',
		component: statistics_tab,
		children: [{
				path: '/',
				component: tabsection
			},
			{
				path: 'list',
				component: tablist
			}

		]
	},
	{
		path: '/reserve',
		component: reserve
	},
	{
		path: '/library',
		component: library
	},
	{
		path: '/price',
		component: price
	},
	{
		path: '/vehicle',
		component: vehicle
	},
	{
		path: '/vehicle_step2',
		component: vehicle_step2
	},
	{
		path: '/carInfo',
		component: carInfo
	},
	{
		path: '/special',
		component: special
	},
	{
		path: '/shelves_step1',
		component: shelves_step1
	},
	{
		path: '/shelves_step2',
		component: shelves_step2
	},
	{
		path: '/customer',
		component: customer,
		children: [{
				path: '/',
				component: customer_screen,
			},
			{
				path: '/customer_info',
				component: customer_screen_info
			},
			{
				path: '/customer_edit',
				component: customer_edit
			},
			{
				path: '/addIntentions',
				component: addIntentions
			},
			{
				path: '/follow_all',
				component: follow_all
			},
			{
				path: '/follow_history',
				component: follow_history
			},
		]
	},
	{
		path: '/customer_add',
		component: customer_add
	},
	// { path:'/customer_info',component:customer_info,
	//   children:[

	//   ]
	// },
	{
		path: '/follow',
		component: follow
	},
	{
		path: '/addIntention',
		component: addIntention
	},
	{
		path: '/infoIntention',
		component: infoIntention
	},

	{
		path: '/notice',
		component: notice
	},
	{
		path: '/notice/:id',
		component: noticeDetial
	},
	{
		path: '/staff',
		component: staffList
	},
	{
		path: '/staff/:id',
		component: editStaff
	},
	{
		path: '/addStaff',
		component: addStaff
	},

	{
		path: '/show',
		component: show
	},
	{
		path: '/show/brandDetial',
		component: brandDetial
	},
	{
		path: '/show/colorDetial',
		component: colorDetial
	},
	{
		path: '/show/modelDetial',
		component: modelDetial
	},
	{
		path: '/show/priceDetial',
		component: priceDetial
	},
	{
		path: '/show/totalDetial',
		component: totalDetial
	},
	{
		path: '/car_select_template',
		component: select_template
	},
	{
		path: '/car_cars_template',
		component: cars_template
	},
	{
		path: '/cars_favorite',
		component: cars_favorite
	},
	{
		path: '/user_feedback',
		component: user_feedback
	},
	{
		path: '/user_feedback_history',
		component: user_feedback_history
	},
	{
		path: '/about',
		component: about
	},

	{
		path: '/check',
		component: checkList
	},
	{
		path: '/check/:id',
		component: checkDetial
	},
	{
		path: '/customer_mail',
		component: customer_mail
	},
	{
		path: '/retrieve',
		component: retrieve
	},
	{
		path: '/cooperation',
		component: cooperation
	},
	{
		path: '/dismissal/:id',
		component: dismissal
	},
	{
		path: '/edit/:id',
		component: edit
	},
	{
		path: '/password',
		component: password
	},
	{
		path: '/lease',
		component: lease
	}
]


// Vuex
// Vue.use(Vuex);

// let store = Vuex.Store({
//   // ...
// })

//字体图

import carOptions from 'src/assembly/carOptions.vue'
import globalPopup from 'src/assembly/globalPopup.vue'

Vue.component('carOptions', carOptions)
Vue.component('globalPopup', globalPopup)

Vonic.app.setConfig('routerOptions', {
	'history': true,
	'saveScrollPosition': true
})

//vuex
import store from './vuex/store.js'

Vue.use(Vonic.app, {
	routes,
	store,
})